package com.yy.auth.server.config.other;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description 跨域问题 (CORS)
 * @Date 2025/10/10 上午11:47
 * @Author yanglin
 **/
@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/oauth2/**")
                .allowedOrigins("http://localhost:8081", "http://localhost:8082")
                .allowedMethods("GET", "POST")
                .allowCredentials(true)
                .maxAge(3600);

        //registry.addMapping("/login")
        //        .allowedOrigins("http://localhost:8081", "http://localhost:8082")
        //        .allowedMethods("POST")
        //        .allowCredentials(true)
        //        .maxAge(3600);
        //
        //registry.addMapping("/**")
        //        .allowedOrigins("http://localhost:8081", "http://localhost:8082")
        //        .allowedMethods("GET", "POST")
        //        .allowCredentials(true);
    }
}
